import { Component, OnInit } from '@angular/core';
import { MessageService } from "../message.service";

@Component({
  selector: 'app-message',
  templateUrl: './message.component.html',
  styleUrls: ['./message.component.css']
})
export class MessageComponent implements OnInit {

  messages: string[];

  constructor(private messageService: MessageService) { }

  ngOnInit(): void {
    this.load();
  }

  clear(): void {
    this.messageService.clear();
    this.load();
  }

  private load(): void {
    this.messages = this.messageService.getMessages();
  }
}
